import { ElMessage, ElNotification, ElMessageBox } from "element-plus";

const messageInfo = {
  //dangerouslyUseHTMLString：是否开启html渲染
  success: (msg, duration = 2000, dangerouslyUseHTMLString = false) => {

    ElNotification({
      type: "success",
      message: msg,
      dangerouslyUseHTMLString,
      duration: duration,
    });
  },
  notific: {
    success: (msg, duration = 2000, dangerouslyUseHTMLString = false) => {
      ElNotification({
        type: "success",
        message: msg,
        dangerouslyUseHTMLString,
        duration: duration,
      });
    },
    error: (msg, duration = 2000, dangerouslyUseHTMLString = false) => {
      ElNotification({
        type: "error",
        message: msg,
        dangerouslyUseHTMLString,
        duration: duration,
      });
    },
    warning: (msg, duration = 2000, dangerouslyUseHTMLString = false) => {
      ElNotification({
        type: "warning",
        message: msg,
        dangerouslyUseHTMLString,
        duration: duration,
      });
    },
    info: (msg, duration = 2000, dangerouslyUseHTMLString = false) => {
      ElNotification({
        type: "info",
        message: msg,
        dangerouslyUseHTMLString,
        duration: duration,
      });
    }
  },
  toast: {
    success: (msg, duration = 2000, offset = 16) => {
      ElMessage({
        type: "success",
        message: msg,
        duration: duration,
        offset: offset,
      });
    },
    error: (msg, duration = 2000, offset = 16) => {
      ElMessage({
        type: "error",
        message: msg,
        duration: duration,
        offset: offset,
      });
    },
    warning: (msg, duration = 2000, offset = 16) => {
      ElMessage({
        type: "warning",
        message: msg,
        duration: duration,
        offset: offset,
      });
    },
    info: (msg, duration = 2000, offset = 16) => {
      ElMessage({
        type: "info",
        message: msg,
        duration: duration,
        offset: offset,
      });
    }
  },
  confirm: (msg = '提示内容', title = '', confirm = '确定', cancel = '取消', type = 'warning')=>{
    return ElMessageBox.confirm(msg, title, {
      confirmButtonText: confirm,
      cancelButtonText: cancel,
      type: type,
    })
  }
}

export default messageInfo